/*=============================================================================
// File Name: 
// Author:  Wood.Wang
// Date:
// Message:
// Copyright 2012,All right is reserved;

=============================================================================*/
#ifndef _RPR0521RS__H_
#define _RPR0521RS__H_


#ifdef __cplusplus
extern "C" {
#endif

#include "drv_i2c.h"


#define RPR0521RS_DEVICE_ADDRESS                   (0x38)    // 7bit Addrss
#define RPR0521RS_PART_ID_VAL                      (0x0A)
#define RPR0521RS_MANUFACT_ID_VAL                  (0xE0)

#define RPR0521RS_SYSTEM_CONTROL                   (0x40)
#define RPR0521RS_MODE_CONTROL                     (0x41)
#define RPR0521RS_ALS_PS_CONTROL                   (0x42)
#define RPR0521RS_PS_CONTROL                       (0x43)
#define RPR0521RS_PS_DATA_LSB                      (0x44)
#define RPR0521RS_ALS_DATA0_LSB                    (0x46)
#define RPR0521RS_ALS_DATA1_LSB                    (0x48)
#define RPR0521RS_INTERRUPT_CONTROL                (0x4A)
#define RPR0521RS_PS_TH_LSB	                       (0x4B)
#define RPR0521RS_PS_TL_LSB                        (0x4D)
#define RPR0521RS_ALS_DATA0_TH_LSB                 (0x4F)
#define RPR0521RS_ALS_DATA0_TL_LSB                 (0x51)
#define RPR0521RS_PS_OFFSET_LSB                    (0x53)
#define RPR0521RS_MANUFACT_ID                      (0x92)




#define RPR0521RS_MODE_CONTROL_MEASTIME_100_100MS  (6 << 0)
#define RPR0521RS_MODE_CONTROL_PS_EN               (1 << 6)
#define RPR0521RS_MODE_CONTROL_ALS_EN              (1 << 7)

#define RPR0521RS_ALS_PS_CONTROL_LED_CURRENT_100MA (2 << 0)
#define RPR0521RS_ALS_PS_CONTROL_DATA1_GAIN_X1     (0 << 2)
#define RPR0521RS_ALS_PS_CONTROL_DATA0_GAIN_X1     (0 << 4)

#define RPR0521RS_PS_CONTROL_PS_GAINX1             (0 << 4)

#define RPR0521RS_MODE_CONTROL_VAL                 (RPR0521RS_MODE_CONTROL_MEASTIME_100_100MS | RPR0521RS_MODE_CONTROL_PS_EN | RPR0521RS_MODE_CONTROL_ALS_EN)
#define RPR0521RS_ALS_PS_CONTROL_VAL               (RPR0521RS_ALS_PS_CONTROL_DATA0_GAIN_X1 | RPR0521RS_ALS_PS_CONTROL_DATA1_GAIN_X1 | RPR0521RS_ALS_PS_CONTROL_LED_CURRENT_100MA)
#define RPR0521RS_PS_CONTROL_VAL                   (RPR0521RS_PS_CONTROL_PS_GAINX1)




extern  uint8_t RPR0521RS_Init(void);
extern  void RPR0521RS_get_rawdata(uint8_t *buff);
extern  void RPR0521RS_get_psalsval(unsigned int *ps, float *als);


extern  uint8_t RPR0521RS_read_int(void);
extern  void RPR0521RS_write_int(uint8_t intvalue);
extern  void RPR0521RS_Set_PS_threshold(uint16_t ps_high,uint16_t ps_low);
extern  void RPR0521RS_Set_ALS_threshold(uint16_t als_high,uint16_t als_low);

extern  void RPR0521RS_power_down(void);


#ifdef __cplusplus
}
#endif

#endif // _RPR0521RS__H_


